<div class="row">
    <h2 class="info_page">Your Mobile Planet Contact Information</h2>

    <div class="info_page"><div>Congratulations! You can now add your contact details to the  "Dermapen" Multi-Platform Mobile Application.</div>
        <div>Now Smart Mobile Device users around the world can easily and quickly call you, email you, visit your website and even get directions straight to your door, with one single tap on the Smart Mobile Device they have with them constantly!</div>
        <div>Below please enter your details precisely. On the iPhone you can see how your contact details will be displayed to all on the Mobile Planet.</div>
        <div>This is free for you to do, but please make sure your details are correct as any future changes will incur relevant administration cost.</div>
        <div>The  "Dermapen" Multi-Platform Application will be available globaly soon - this is your opportunity to be apart of it!</div></div></div>
    <div id ="example"></div> 
    <div class="form">

        <?php
        $form = $this->beginWidget('CActiveForm', array(
            'id' => 'tplocation-form',
            'enableAjaxValidation' => true,
//            'action' => 'http:\\appcamel.com',
//            'onsubmit'=>"return confirm('Are you sure you want to submit?')"
        ));
        ?>

        <p class="note">Fields with <span class="required">*</span> are required.</p>

        <?php echo $form->errorSummary($model); ?>

        <div class="row">
            <?php echo $form->labelEx($model, 'name'); ?> ( limit of 20 characters ) </br>
            <?php echo $form->textArea($model, 'name', array('rows' => 1, 'cols' => 50, 'maxlength' => 20)); ?>
            <?php echo $form->error($model, 'name'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model, 'address'); ?> ( limit of 36 characters )</br>
            <?php echo $form->textArea($model, 'address', array('rows' => 2, 'cols' => 50, 'maxlength' => 36)); ?>
            <?php echo $form->error($model, 'address'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model, 'telephone_land'); ?> ( limit of 20 characters )</br>
            <?php echo $form->textArea($model, 'telephone_land', array('rows' => 1, 'cols' => 50, 'maxlength' => 20)); ?>
            <?php echo $form->error($model, 'telephone_land'); ?>
        </div>

        <div class="row">
            <?php echo $form->labelEx($model, 'telephone_mob1'); ?> ( limit of 20 characters )</br>
            <?php echo $form->textArea($model, 'telephone_mob1', array('rows' => 1, 'cols' => 50, 'maxlength' => 20)); ?>
            <?php echo $form->error($model, 'telephone_mob1'); ?>
        </div>
        
        <div class="row">
            <?php echo $form->labelEx($model, 'email'); ?>( limit of 30 characters )</br>
            <?php echo $form->textArea($model, 'email', array('rows' => 1, 'cols' => 50, 'maxlength' => 30)); ?>
            <?php echo $form->error($model, 'email'); ?>
        </div>
        
        <div class="row">
            <?php echo $form->labelEx($model, 'telephone_mob2'); ?>( limit of 40 characters )</br>
            <?php echo $form->textArea($model, 'telephone_mob2', array('rows' => 1, 'cols' => 50, 'maxlength' => 40)); ?>
            <?php echo $form->error($model, 'telephone_mob2'); ?>
        </div>


        <div class="row buttons">
            <?php
            $arrayAuthRoleItems = Yii::app()->authManager->getAuthItems(2, Yii::app()->user->getId());
            $arrayKeys = array_keys($arrayAuthRoleItems);
            $role = strtolower($arrayKeys[0]);
//                echo $role;
            if ($role == 'root')
                echo CHtml::Button('Send email with link to this page', array('onclick' => "
		
		$.ajax({
                                            'type':'POST',
                                            'url':'" . $this->createUrl('tpLocation/email') . "',
                                            'data':({'email': $('#TPLocation_email').val(),'id':" . $model->id . "}),
                                            'cache':false,
                                        });
                                        alert('Email sended');
		
		"));
            ?>
        </div>

        <div class="row">
            <p class="info_page">Please zoom in to your exact location. Move pin so it is in the exact location of your address. This is where you will be located in the map on the Mutli-Platform Mobile Application. Accuracy is important as app citizens will be directed to that exact pin location.</p>
            <?php
            //
            // ext is your protected.extensions folder
            // gmaps means the subfolder name under your protected.extensions folder
            // 
            $location = json_decode($model->location);
            Yii::import('ext.EGMap.*');

            $gMap = new EGMap();
            $gMap->zoom = 12;
            $gMap->width = '100%';
            $gMap->height = 600;
            $mapTypeControlOptions = array(
                'position' => EGMapControlPosition::LEFT_BOTTOM,
                'style' => EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU
            );

            $gMap->mapTypeControlOptions = $mapTypeControlOptions;

            $gMap->setCenter($location->latitude, $location->longitude);

            //$icon = new EGMapMarkerImage("http://dermapen.com/images/orderd.png");
            //$icon->setSize(32, 37);
            //$icon->setAnchor(16, 16.5);
            //$icon->setOrigin(0, 0); 
            // Saving coordinates after user dragged our marker.
            $dragevent = new EGMapEvent('dragend', "function (event) { 
			var loc={
				'latitude':event.latLng.lat(), 
				'longitude':event.latLng.lng()
				}
			$('#temp_location').val(JSON.stringify(loc));
			;}", false, EGMapEvent::TYPE_EVENT_DEFAULT);




            // Create marker
            $marker = new EGMapMarker($location->latitude, $location->longitude, array('title' => 'You are here'), 'marker', array('dragevent' => $dragevent));
            //$marker->addHtmlInfoWindow($info_window_a);
            $marker->draggable = true;
            $gMap->addMarker($marker);

            $gMap->renderMap();
            ?>
        </div>

        <div class="row">
            <input type="text" id="temp_location" hidden=false></input>
            <?php echo $form->textField($model, 'location', array('hidden' => false)); ?>
        </div>
        <div class="row buttons">
            <?php echo CHtml::Button('Set my place', array('onclick' => '$(\'#TPLocation_location\').val($(\'#temp_location\').val()); alert(\'Done\');')); ?>
            <?php 
//            if ($role != 'root') 
            echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('confirm'=>'Are you sure you want to save?')); 
//            else {?>
            <!--<form action="<form handler>" method="post" onsubmit="return confirm('Are you sure you want to submit?')">-->
            <?php //} ?>
        </div>

        <?php $this->endWidget(); ?>

    </div><!-- form -->